<template>
<div class="icons">
	<swiper :options="swiperOption">
		<swiper-slide v-for="(page,index) in pages" :key="index">
			<div class="icon" v-for="item in page">
				<div class="icon-img">
					<img class="icon-img-content" :key="item.id" :src="item.imgUrl">
				</div>
				<p class="icon-desc">{{item.desc}}</p>
			</div>
		</swiper-slide>
	  <div class="swiper-pagination"  slot="pagination"></div>
	</swiper>
</div>
</template>

<script>
export default {
	name: 'HomeIcons',
	props: {
		list: Array
	},
	data () {
		return {
			swiperOption: {
				autoplay: false
   		}
		}
	},
	computed: {
		pages () {
			const pages = []
			this.list.forEach((item,index) => {
				const page = Math.floor(index / 8) /*计算页面展示数量*/
				if (!pages[page]){
					pages[page] = []
				}
				pages[page].push(item)
			})
			return pages
		}
	}
}
</script>

<style lang="stylus" scoped="">
@import '~styles/varibles.styl'
@import '~styles/mixins.styl'
.icons >>> .swiper-container
	width: 100%
.icons
	padding:.1rem 0 .3rem 0
	.icon
		width: 25%
		float: left
		.icon-img
			bottom: .44rem
			padding: .17rem
			text-align: center
			.icon-img-content
				width:1.2rem
				height:1.2rem
		.icon-desc
			height: .44rem
			line-height: .44rem
			text-align: center
			color: $textColor
			ellipsis()
</style>